/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "zobjects_gtk.h"

#define ZOBJECTS_GTK_OBJECT_DATA_KEY_ROW_DATA		"zobjects_gtk_object_data_key_row_data"

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_Create_guiwindow;
int ZlangInvokeFunction_guilistbox_Create_guiwindow( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \

	EVAL_GTK_WIDGET_NEW_IN_CREATE( guilistbox_common->gtk_widget , gtk_list_box_new() )
	SET_CONTROL_DEFAULT_STYLE( in1 , guilistbox_common->gtk_widget )
	/*
	guilistbox_common->gtk_outer_widget = gtk_scrolled_window_new() ;
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(guilistbox_common->gtk_outer_widget) , GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC );
	gtk_scrolled_window_set_child( GTK_SCROLLED_WINDOW(guilistbox_common->gtk_outer_widget) , guilistbox_common->gtk_widget );
	*/

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guilistbox_common->guiwindow_obj , in1 )

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_Create_guiwindow_functionptr;
int ZlangInvokeFunction_guilistbox_Create_guiwindow_functionptr( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \

	EVAL_GTK_WIDGET_NEW_IN_CREATE( guilistbox_common->gtk_widget , gtk_list_box_new() )
	SET_CONTROL_DEFAULT_STYLE( in1 , guilistbox_common->gtk_widget )

	/*
	guilistbox_common->gtk_outer_widget = gtk_scrolled_window_new() ;
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(guilistbox_common->gtk_outer_widget) , GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC );
	gtk_scrolled_window_set_child( GTK_SCROLLED_WINDOW(guilistbox_common->gtk_outer_widget) , guilistbox_common->gtk_widget );
	*/

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guilistbox_common->guiwindow_obj , in1 )

	ADD_CONTROL_GENERAL_CALLBACK_IN_CREATE( guilistbox_common->guiwindow_obj , out1 , GTK_EVENT_SELECTED_ROWS_CHANGED , in2 )

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SetLabelAlignment_float;
int ZlangInvokeFunction_guilistbox_SetLabelAlignment_float( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	float						alignment ;
	gfloat						*p_alignment = NULL ;

	CallRuntimeFunction_float_GetFloatValue( rt , in1 , & alignment );

	p_alignment = g_malloc( sizeof(gfloat) ) ;
	(*p_alignment) = alignment ;
	g_object_set_data_full( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN , p_alignment , g_free );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_ShowSeparators_bool;
int ZlangInvokeFunction_guilistbox_ShowSeparators_bool( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					b ; ;

	CallRuntimeFunction_bool_GetBoolValue( rt , in1 , & b );

	gtk_list_box_set_show_separators( GTK_LIST_BOX(guilistbox_common->gtk_widget) , b );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_AppendStringItem_string;
int ZlangInvokeFunction_guilistbox_AppendStringItem_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	char						*str = NULL ;
	GtkWidget					*label = NULL ;
	gfloat						*p_alignment = NULL ;

	CallRuntimeFunction_string_GetStringValue( rt , in1 , & str , NULL );

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	label = gtk_label_new( str );
	if( p_alignment )
		gtk_label_set_xalign( GTK_LABEL(label) , (*p_alignment) );
	gtk_list_box_insert( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , GTK_WIDGET(label) , -1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_InsertStringItem_int_string;
int ZlangInvokeFunction_guilistbox_InsertStringItem_int_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	char						*str = NULL ;
	GtkWidget					*label = NULL ;
	gfloat						*p_alignment = NULL ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );
	CallRuntimeFunction_string_GetStringValue( rt , in2 , & str , NULL );

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	label = gtk_label_new( str );
	if( p_alignment )
		gtk_label_set_xalign( GTK_LABEL(label) , (*p_alignment) );
	gtk_list_box_insert( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , GTK_WIDGET(label) , row_no-1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SetStringItem_int_string;
int ZlangInvokeFunction_guilistbox_SetStringItem_int_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	GtkListBoxRow					*listbox_row = NULL ;
	char						*str = NULL ;
	GtkWidget					*label = NULL ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );
	CallRuntimeFunction_string_GetStringValue( rt , in2 , & str , NULL );

	listbox_row = gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , row_no-1 ) ;
	label = gtk_list_box_row_get_child( listbox_row ) ;
	if( GTK_IS_LABEL(label) )
		gtk_label_set_label( GTK_LABEL(label) , str );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_AppendStringItems_vargs;
int ZlangInvokeFunction_guilistbox_AppendStringItems_vargs( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	int						count ;
	int						no ;
	struct ZlangObject				*inN = NULL ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	char						*str = NULL ;
	GtkWidget					*label = NULL ;
	gfloat						*p_alignment = NULL ;

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	count = GetInputParameterCountInLocalObjectStack( rt ) ;
	for( no = 1 ; no <= count ; no++ )
	{
		inN = GetInputParameterInLocalObjectStack( rt , no ) ;
		if( inN == NULL )
		{
			return ThrowErrorException( rt , EXCEPTION_CODE_GENERAL , EXCEPTION_MESSAGE_INTERNAL_ERROR );
		}

		if( ! IsTypeOf( rt , inN , GetStringObjectInRuntimeObjectsHeap(rt) ) )
		{
			return ThrowErrorException( rt , EXCEPTION_CODE_GENERAL , EXCEPTION_MESSAGE_OBJECT_TYPE_INVALID );
		}

		CallRuntimeFunction_string_GetStringValue( rt , inN , & str , NULL );

		label = gtk_label_new( str );
		if( p_alignment )
			gtk_label_set_xalign( GTK_LABEL(label) , (*p_alignment) );
		gtk_list_box_insert( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , GTK_WIDGET(label) , -1 );
	}

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_AppendItem_object_object;
int ZlangInvokeFunction_guilistbox_AppendItem_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*new_listbox_row_obj = NULL ;
	GtkWidget					*listbox_row = NULL ;
	GtkWidget					*listbox_item_label = NULL ;
	gfloat						*p_alignment = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	int						nret = 0 ;

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	if( in2 == NULL || IsObjectPropertiesEntityNull(in2) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}

	listbox_row = gtk_list_box_row_new() ;

	nret = CloneObject( rt , & new_listbox_row_obj , NULL , in2 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}
	g_object_set_data_full( G_OBJECT(listbox_row) , ZOBJECTS_GTK_OBJECT_DATA_KEY_ROW_DATA , new_listbox_row_obj , FastDestroyObject );

	nret = ToString( rt , in1 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );
	listbox_item_label = gtk_label_new( str );
	if( p_alignment )
		gtk_label_set_xalign( GTK_LABEL(listbox_item_label) , (*p_alignment) );
	gtk_list_box_row_set_child( GTK_LIST_BOX_ROW(listbox_row) , listbox_item_label );

	gtk_list_box_append( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , listbox_row );

	gtk_widget_show( listbox_row );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_InsertItem_int_object_object;
int ZlangInvokeFunction_guilistbox_InsertItem_int_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	struct ZlangObject				*new_listbox_row_obj = NULL ;
	GtkWidget					*listbox_row = NULL ;
	GtkWidget					*listbox_item_label = NULL ;
	gfloat						*p_alignment = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	int						nret = 0 ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	if( in3 == NULL || IsObjectPropertiesEntityNull(in3) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}

	listbox_row = gtk_list_box_row_new() ;

	nret = CloneObject( rt , & new_listbox_row_obj , NULL , in3 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}
	g_object_set_data_full( G_OBJECT(listbox_row) , ZOBJECTS_GTK_OBJECT_DATA_KEY_ROW_DATA , new_listbox_row_obj , FastDestroyObject );

	nret = ToString( rt , in2 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );
	listbox_item_label = gtk_label_new( str );
	if( p_alignment )
		gtk_label_set_xalign( GTK_LABEL(listbox_item_label) , (*p_alignment) );
	gtk_list_box_row_set_child( GTK_LIST_BOX_ROW(listbox_row) , listbox_item_label );

	gtk_list_box_insert( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , listbox_row , row_no-1 );

	gtk_widget_show( listbox_row );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SetItem_int_object_object;
int ZlangInvokeFunction_guilistbox_SetItem_int_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ; \
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	struct ZlangObject				*new_listbox_row_obj = NULL ;
	GtkListBoxRow					*listbox_row = NULL ;
	GtkWidget					*listbox_item_label = NULL ;
	gfloat						*p_alignment = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	int						nret = 0 ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	p_alignment = g_object_get_data( G_OBJECT(guilistbox_common->gtk_widget) , G_OBJECT_SET_DATA_KEY_GUILISTBOX_XALIGN ) ;

	if( in3 == NULL || IsObjectPropertiesEntityNull(in3) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}

	listbox_row = gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , row_no-1 ) ;

	nret = CloneObject( rt , & new_listbox_row_obj , NULL , in3 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}
	g_object_set_data_full( G_OBJECT(listbox_row) , ZOBJECTS_GTK_OBJECT_DATA_KEY_ROW_DATA , new_listbox_row_obj , FastDestroyObject );

	nret = ToString( rt , in2 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );
	listbox_item_label = gtk_label_new( str );
	if( p_alignment )
		gtk_label_set_xalign( GTK_LABEL(listbox_item_label) , (*p_alignment) );
	gtk_list_box_row_set_child( GTK_LIST_BOX_ROW(listbox_row) , listbox_item_label );

	gtk_widget_show( GTK_WIDGET(listbox_row) );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SetSelectedRowsChangedEventCallback_functionptr;
int ZlangInvokeFunction_guilistbox_SetSelectedRowsChangedEventCallback_functionptr( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;

	ADD_CONTROL_GENERAL_CALLBACK_IN_CREATE( guilistbox_common->guiwindow_obj , obj , GTK_EVENT_SELECTED_ROWS_CHANGED , in1 )

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SetRowActivatedEventCallback_functionptr;
int ZlangInvokeFunction_guilistbox_SetRowActivatedEventCallback_functionptr( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;

	ADD_CONTROL_LISTBOXROW_CALLBACK_IN_CREATE( guilistbox_common->guiwindow_obj , obj , GTK_EVENT_ROW_ACTIVATED , in1 )

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_SelectRow_int;
int ZlangInvokeFunction_guilistbox_SelectRow_int( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						index ;
	GtkListBoxRow					*listbox_row = NULL ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & index );

	listbox_row = gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , index-1 ) ;
	gtk_list_box_select_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , listbox_row );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZLANG_INVOKE_FUNCTION_guiwidget_all_common_functions( listbox )

ZLANG_INVOKE_FUNCTION_guictl_all_common_functions( listbox )

static int gtk_list_box_get_n_items( GtkWidget *widget )
{
	int		count ;
	GtkWidget	*child = NULL ;

	count = 0 ;
	child = gtk_widget_get_first_child( widget ) ;
	while( child )
	{
		count++;
		child = gtk_widget_get_next_sibling( child ) ;
	}

	return count;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_Remove_int;
int ZlangInvokeFunction_guilistbox_Remove_int( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	int32_t						item_count ;
	GtkListBoxRow					*listbox_row = NULL ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	listbox_row = gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , row_no-1 ) ;
	if( listbox_row == NULL )
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , in1 , FALSE );
		return 0;
	}
	gtk_list_box_remove( GTK_LIST_BOX(guilistbox_common->gtk_widget) , GTK_WIDGET(listbox_row) );

	item_count = gtk_list_box_get_n_items( guilistbox_direct_prop->common.gtk_widget ) ;
	if( row_no > item_count )
		gtk_list_box_select_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , item_count-1 ) );
	else
		gtk_list_box_select_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , gtk_list_box_get_row_at_index( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) , row_no-1 ) );

	CallRuntimeFunction_bool_SetBoolValue( rt , in1 , TRUE );
	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_RemoveAll;
int ZlangInvokeFunction_guilistbox_RemoveAll( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = & (guilistbox_direct_prop->common) ;

	gtk_list_box_remove_all( GTK_LIST_BOX(guilistbox_common->gtk_widget) );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_GetItemCount;
int ZlangInvokeFunction_guilistbox_GetItemCount( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox	*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t					item_count ;

	item_count = gtk_list_box_get_n_items( guilistbox_direct_prop->common.gtk_widget ) ;
	CallRuntimeFunction_int_SetIntValue( rt , out1 , item_count );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_GetSelectedRowNo;
int ZlangInvokeFunction_guilistbox_GetSelectedRowNo( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox	*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkListBoxRow				*gtk_listbox_row = NULL ;
	int32_t					index ;

	gtk_listbox_row = gtk_list_box_get_selected_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) ) ;
	if( gtk_listbox_row == NULL )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	index = gtk_list_box_row_get_index( gtk_listbox_row ) ;
	CallRuntimeFunction_int_SetIntValue( rt , out1 , index+1 );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_GetSelectedRowString;
int ZlangInvokeFunction_guilistbox_GetSelectedRowString( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox	*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkListBoxRow				*gtk_listbox_row = NULL ;
	GtkWidget				*gtk_label = NULL ;
	char					*str = NULL ;

	gtk_listbox_row = gtk_list_box_get_selected_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) ) ;
	if( gtk_listbox_row == NULL )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	gtk_label = gtk_widget_get_first_child( GTK_WIDGET(gtk_listbox_row) ) ;
	if( ! GTK_IS_LABEL(gtk_label) )
	{
		UnreferObject( rt , out1 );
		return 0;
	}
	str = (char*)gtk_label_get_text( GTK_LABEL(gtk_label) ) ;
	CallRuntimeFunction_string_SetStringValue( rt , out1 , str , STRLEN_OF_STRING );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guilistbox_GetSelectedRowObject;
int ZlangInvokeFunction_guilistbox_GetSelectedRowObject( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox	*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkListBoxRow				*gtk_listbox_row = NULL ;
	struct ZlangObject			*listbox_row_obj = NULL ;
	int					nret = 0 ;

	gtk_listbox_row = gtk_list_box_get_selected_row( GTK_LIST_BOX(guilistbox_direct_prop->common.gtk_widget) ) ;
	if( gtk_listbox_row == NULL )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	listbox_row_obj = g_object_get_data( G_OBJECT(gtk_listbox_row) , ZOBJECTS_GTK_OBJECT_DATA_KEY_ROW_DATA ) ;
	nret = ReferObject( rt , out1 , listbox_row_obj ) ;
	if( nret )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	return 0;
}

ZlangCreateDirectPropertyFunction ZlangCreateDirectProperty_guilistbox;
void *ZlangCreateDirectProperty_guilistbox( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox		*guilistbox_prop = NULL ;
	struct ZlangDirectProperty_guiwidget_common	*guilistbox_common = NULL ;
	
	guilistbox_prop = (struct ZlangDirectProperty_guilistbox *)ZLMALLOC( sizeof(struct ZlangDirectProperty_guilistbox) ) ;
	if( guilistbox_prop == NULL )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_ALLOC , "alloc memory for entity" )
		return NULL;
	}
	memset( guilistbox_prop , 0x00 , sizeof(struct ZlangDirectProperty_guilistbox) );

	guilistbox_common = (struct ZlangDirectProperty_guiwidget_common *)guilistbox_prop ;
	guilistbox_common->gtk_widget_type_id = GTK_TYPE_LIST_BOX ;

	INIT_ZLANGDIRECTPROPERTY_guiwidget_common(guilistbox)
	
	return guilistbox_prop;
}

ZlangDestroyDirectPropertyFunction ZlangDestroyDirectProperty_guilistbox;
void ZlangDestroyDirectProperty_guilistbox( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guilistbox	*guilistbox_direct_prop = GetObjectDirectProperty(obj) ;
	
	CLEAN_ZLANGDIRECTPROPERTY_guiwidget_common(guilistbox)

	ZLFREE( guilistbox_direct_prop );
	
	return;
}

ZlangSummarizeDirectPropertySizeFunction ZlangSummarizeDirectPropertySize_guilistbox;
void ZlangSummarizeDirectPropertySize_guilistbox( struct ZlangRuntime *rt , struct ZlangObject *obj , size_t *summarized_obj_size , size_t *summarized_direct_prop_size )
{
	SUMMARIZE_SIZE( summarized_direct_prop_size , sizeof(struct ZlangDirectProperty_guilistbox) )
	return;
}

static struct ZlangDirectFunctions direct_funcs_guilistbox =
	{
		ZLANG_OBJECT_guilistbox , /* char *ancestor_name */
		
		ZlangCreateDirectProperty_guilistbox , /* ZlangCreateDirectPropertyFunction *create_entity_func */
		ZlangDestroyDirectProperty_guilistbox , /* ZlangDestroyDirectPropertyFunction *destroy_entity_func */
		
		NULL , /* ZlangFromCharPtrFunction *from_char_ptr_func */
		NULL , /* ZlangToStringFunction *to_string_func */
		NULL , /* ZlangFromDataPtrFunction *from_data_ptr_func */
		NULL , /* ZlangGetDataPtrFunction *get_data_ptr_func */
		
		NULL , /* ZlangOperatorFunction *oper_PLUS_func */
		NULL , /* ZlangOperatorFunction *oper_MINUS_func */
		NULL , /* ZlangOperatorFunction *oper_MUL_func */
		NULL , /* ZlangOperatorFunction *oper_DIV_func */
		NULL , /* ZlangOperatorFunction *oper_MOD_func */
		
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NEGATIVE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NOT_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_BIT_REVERSE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_PLUS_PLUS_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_MINUS_MINUS_func */
		
		NULL , /* ZlangCompareFunction *comp_EGUAL_func */
		NULL , /* ZlangCompareFunction *comp_NOTEGUAL_func */
		NULL , /* ZlangCompareFunction *comp_LT_func */
		NULL , /* ZlangCompareFunction *comp_LE_func */
		NULL , /* ZlangCompareFunction *comp_GT_func */
		NULL , /* ZlangCompareFunction *comp_GE_func */
		
		NULL , /* ZlangLogicFunction *logic_AND_func */
		NULL , /* ZlangLogicFunction *logic_OR_func */
		
		NULL , /* ZlangLogicFunction *bit_AND_func */
		NULL , /* ZlangLogicFunction *bit_XOR_func */
		NULL , /* ZlangLogicFunction *bit_OR_func */
		NULL , /* ZlangLogicFunction *bit_MOVELEFT_func */
		NULL , /* ZlangLogicFunction *bit_MOVERIGHT_func */
		
		ZlangSummarizeDirectPropertySize_guilistbox , /* ZlangSummarizeDirectPropertySizeFunction *summarize_direct_prop_size_func */
	} ;

ZlangImportObjectFunction ZlangImportObject_guilistbox;
struct ZlangObject *ZlangImportObject_guilistbox( struct ZlangRuntime *rt )
{
	struct ZlangObject	*obj = NULL ;
	struct ZlangFunction	*func = NULL ;
	int			nret = 0 ;
	
	nret = ImportObject( rt , & obj , ZLANG_OBJECT_guilistbox , & direct_funcs_guilistbox , sizeof(struct ZlangDirectFunctions) , NULL ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_LINK_FUNC_TO_ENTITY , "import object to global objects heap" )
		return NULL;
	}
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_Create_guiwindow , ZLANG_OBJECT_guilistbox , "Create" , ZLANG_OBJECT_guiwindow,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_Create_guiwindow_functionptr , ZLANG_OBJECT_guilistbox , "Create" , ZLANG_OBJECT_guiwindow,NULL , ZLANG_OBJECT_functionptr,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SetLabelAlignment_float , ZLANG_OBJECT_guilistbox , "SetLabelAlignment" , ZLANG_OBJECT_float,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_ShowSeparators_bool , ZLANG_OBJECT_guilistbox , "ShowSeparators" , ZLANG_OBJECT_bool,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_AppendStringItem_string , ZLANG_OBJECT_guilistbox , "AppendStringItem" , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_InsertStringItem_int_string , ZLANG_OBJECT_guilistbox , "InsertStringItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SetStringItem_int_string , ZLANG_OBJECT_guilistbox , "SetStringItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_AppendStringItems_vargs , ZLANG_OBJECT_guilistbox , "AppendStringItems" , ZLANG_OBJECT_vargs,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_AppendItem_object_object , ZLANG_OBJECT_guilistbox , "AppendItem" , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_InsertItem_int_object_object , ZLANG_OBJECT_guilistbox , "InsertItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SetItem_int_object_object , ZLANG_OBJECT_guilistbox , "SetItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SetSelectedRowsChangedEventCallback_functionptr , ZLANG_OBJECT_guilistbox , "SetSelectedRowsChangedEventCallback" , ZLANG_OBJECT_functionptr,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SetRowActivatedEventCallback_functionptr , ZLANG_OBJECT_guilistbox , "SetRowActivatedEventCallback" , ZLANG_OBJECT_functionptr,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_SelectRow_int , ZLANG_OBJECT_guilistbox , "SelectRow" , ZLANG_OBJECT_int,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guiwidget_all_common_functions( listbox )

	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guictl_all_common_functions( listbox )

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_Remove_int , ZLANG_OBJECT_bool , "Remove" , ZLANG_OBJECT_int,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_RemoveAll , ZLANG_OBJECT_void , "RemoveAll" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_GetSelectedRowNo , ZLANG_OBJECT_int , "GetSelectedRowNo" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_GetSelectedRowString , ZLANG_OBJECT_string , "GetSelectedRowString" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guilistbox_GetSelectedRowObject , ZLANG_OBJECT_object , "GetSelectedRowObject" , NULL ) ;
	if( func == NULL )
		return NULL;

	return obj ;
}

